<template>
  <div>
    <el-form
      size="mini"
      :inline="true"
      :model="formInline"
      class="demo-form-inline"
    >
      <el-form-item label="日期">
        <el-date-picker
          v-model="formInline.region"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="病人编号">
        <el-input v-model="formInline.region"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button>纵向打印</el-button>
      </el-form-item>
      <el-form-item label="送检人">
        <el-select v-model="formInline.region">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button>验证送检人</el-button>
        <el-button>批量送检</el-button>
      </el-form-item>
    </el-form>
    <el-form
      size="mini"
      :inline="true"
      :model="formInline"
      class="demo-form-inline"
    >
      <el-form-item label="条码">
        <el-input
          placeholder="请输入条码号"
          v-model="formInline.region"
          class="input-with-select"
        >
          <el-button slot="append" icon="el-icon-search"></el-button>
        </el-input>
      </el-form-item>
      <el-form-item label="院区">
        <el-select v-model="formInline.region">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="签收状态">
        <el-select v-model="formInline.region">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button>清空</el-button>
        <el-button>打印</el-button>
      </el-form-item>
      <el-form-item label="签收人">
        <el-select v-model="formInline.region">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button>查询</el-button>
        <el-button>保存</el-button>
      </el-form-item>
    </el-form>
    <el-container>
      <el-main>
        <el-table :data="tableData" style="width: 100%" :height="leftheight">
          <el-table-column label="病人信息">
            <el-table-column
              fixed
              type="selection"
              width="55"
            ></el-table-column>
            <el-table-column
              fixed
              prop="bgzkt"
              label="不规则抗体"
              width
            ></el-table-column>
            <el-table-column
              prop="ktscaboxx"
              label="抗体筛查ABO血型"
              width
            ></el-table-column>
            <el-table-column
              prop="ktscczy"
              label="抗体筛查操作员"
              width
            ></el-table-column>
            <el-table-column
              prop="ktscff"
              label="抗体筛查方法"
              width
            ></el-table-column>
            <el-table-column
              prop="ktscrhxx"
              label="抗体筛查RH血型"
              width
            ></el-table-column>
            <el-table-column
              :formatter="formatktscrq"
              prop="ktscrq"
              label="抗体筛查日期"
              width="160"
            ></el-table-column>
            <el-table-column
              prop="ktscsftg"
              label="抗体筛查是否通过"
              width
            ></el-table-column>
            <el-table-column
              prop="qsczy"
              label="签收操作员"
              width
            ></el-table-column>
            <el-table-column
              :formatter="formatqsrq"
              prop="qsrq"
              label="签收日期"
              width="160"
            ></el-table-column>
            <el-table-column prop="qszt" label="签收状态"></el-table-column>
            <el-table-column fixed="right" label="操作" width="100">
              <template slot-scope="scope">
                <el-button
                  @click="updatebbzf(scope.row)"
                  type="text"
                  size="small"
                  >作废</el-button
                >
              </template>
            </el-table-column>
          </el-table-column>
        </el-table>
        <!-- <el-pagination
          class="block"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[100, 200, 300, 400]"
          :page-size="100"
          layout="total, sizes, prev, pager, next, jumper"
          :total="400"
        ></el-pagination> -->
      </el-main>
      <el-aside width="450px">
        <el-table
          :data="tableData"
          :height="leftheight"
          border
          style="width: 100%"
        >
          <el-table-column label="申请项目信息">
            <el-table-column
              prop="date"
              label="项目代码"
              width="180"
            ></el-table-column>
            <el-table-column
              prop="name"
              label="名称"
              width="180"
            ></el-table-column>
            <el-table-column prop="address" label="数量"></el-table-column>
            <el-table-column prop="address" label="费用"></el-table-column>
          </el-table-column>
        </el-table>
      </el-aside>
    </el-container>

    <el-dialog
      title="标本作废"
      :visible.sync="bbzfDiag"
      width="30%"
    >
      <el-form ref="form" :model="bbzfData" label-width="120px">
        <el-form-item label="标本作废原因">
          <el-input type="textarea" v-model="bbzfData.bbzfyy"></el-input>
        </el-form-item>
        <el-form-item label="标本作废备注">
          <el-input type="textarea" v-model="bbzfData.bbzfbz"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="bbzfDiag = false">取 消</el-button>
        <el-button type="primary" @click="bbzfRequest"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import monent from "moment";
export default {
  data() {
    return {
      formInline: {
        user: "",
        region: "",
      },
      tableData: [],
      currentPage: 1,
      leftheight: window.innerHeight - 60 - 20 - 56 - 35 * 2 - 40,
      bbzfDiag:false,
      bbzfData:{
        bbzfbz: "",
        bbzfrq: monent().format("YYYY-MM-DD HH:mm:ss"),
        bbzfyy: "",
      }
    };
  },
  methods: {
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    formatktscrq(row, column) {
      return monent(row.ktscrq).format("YYYY-MM-DD HH:mm:ss");
    },
    formatqsrq(row) {
      return monent(row.qsrq).format("YYYY-MM-DD HH:mm:ss");
    },
    updatebbzf(row) {
      this.bbzfDiag = true
      this.bbzfData['sqdh'] = row["sqdh"]
      this.bbzfData['bbzfczy'] = this.$cookies.get('userInfo').account,
      this.$cookies.get('userInfo')
    },
    //标本作废
    bbzfRequest(){
       this.$ajax.post(`/yx/updatebbzf`, this.bbzfData).then((res) => {
        if (res.code == "0") {
          this.$message({
            message: res.msg,
            type: "success",
          });
          this.bbzfDiag = false
          this.getbbgl()
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    getbbgl(){
      this.$ajax.get(`/yx/getbbgl?qsrq=2019-01-01`, {}).then((res) => {
        if (res.code == "0") {
          this.tableData = res.data;
        } else {
        }
      });
    }
  },
  mounted() {
    this.getbbgl()
  },
};
</script>
<style lang="less" scoped>
.el-form--inline {
  height: 35px;
}
.el-main {
  padding: 0;
}
.block {
  margin-top: 5px;
}
</style>